<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>制作件清单/图纸变更单接收</h1>
    <!--<button type="button" class="btn btn-success pull-right" id="btn-select"-->
            <!--onclick="chushihuayuanshi()">-->
        <!--<span class="Bold">初始化已有数据</span>-->
    <!--</button>-->
    <!--<button type="button" class="btn btn-success pull-right" id="btn-select1"-->
            <!--onclick="chushihua()">-->
        <!--<span class="Bold">初始化看板数据</span>-->
    <!--</button>-->

</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">项目编号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <!--<div class="form-group">-->
                                <!--<label for="query-reportType">分类</label>-->
                                <!--<select id="query-reportType" class="form-control" name="reportType">-->
                                <!--<option value="" selected>全部</option>-->
                                <!--<option value="1">机械</option>-->
                                <!--<option value="2">流体</option>-->
                                <!--<option value="3">自动化</option>-->
                                <!--</select>-->
                                <!--</div>-->
                                <div class="form-group">
                                    <label for="query-malType">类型</label>
                                    <select id="query-malType" class="form-control" name="name">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${specialId}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <div class="form-group">
                                    <label for="query-sectionName">设计科室</label>
                                    <input id="query-sectionName" type="text" name="sectionName" class="form-control"
                                           placeholder="请输入科室">
                                </div>
                                <div class="form-group">
                                    <label for="query-createNameTwo">设计者</label>
                                    <input id="query-createNameTwo" type="text" name="createNameTwo"
                                           class="form-control"
                                           placeholder="请输入设计者">
                                </div>
                                <div class="form-group">
                                    <label for="query-sheetType">下发类型</label>
                                    <select id="query-sheetType" class="form-control" name="sheetType">
                                        <option value="" selected>全部</option>
                                        <option value="1">制作件清单</option>
                                        <option value="0">图纸变更单</option>
                                        <option value="2">制作件清单变更单</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-receiveStatus">接收状态</label>
                                    <select id="query-receiveStatus" class="form-control" name="receiveStatus">
                                        <option value="0" selected>未接收</option>
                                        <option value="1">已接收</option>
                                        <option value="">全部</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-startTime">下发日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker"
                                           name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <!--<div class="form-group">-->
                                    <!--<label for="query-startReceiveTime">工艺接收日期</label>-->
                                    <!--<input id="query-startReceiveTime" type="text" class="form-control datepicker"-->
                                           <!--name="startReceiveTime"-->
                                           <!--readonly="readonly"/>-->
                                    <!--<label for="query-endReceiveTime"> 至 </label>-->
                                    <!--<input id="query-endReceiveTime" type="text" class="form-control datepicker"-->
                                           <!--name="endReceiveTime"-->
                                           <!--readonly="readonly"/>-->
                                <!--</div>-->
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                    <!--<button type="button" class="btn btn-success" id="btn-receive"-->
                            <!--onclick="selected()"  shiro:hasPermission="tec:batchRecep:edit">-->
                        <!--<span class="Bold">批量接收</span>-->
                    <!--</button>-->
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table, typeName = ['', '外购件', '外协件', '原材料'], sheetType = ['图纸变更单', '制作件清单', '制作件清单变更单'];

    /** 选择计划 */
    function selected() {
        let arr = js.table.selectRows(table);
        let arr1=[] ;
        let arr2=[];
        for (i = 0; i < arr.length; i++) {
            arr1.push(arr[i].id);
            arr2.push(arr[i].sheetType);

        }
        if (arr.length < 1) {
            js.modal.alert("请最少选择一条要接收的单据");
            return;
        }
        // location.href = ctx + 'craft/receive/receiveCard?ids='+arri=0
        js.modal.confirm("确定要批量接收选中数据吗?", function () {
            js.post({
                // url:  ctx + 'craft/receive/receiveCard?ids='+arr,
                url: ctx + 'craft/receive/receiveCard',
                data: {arr1: arr1,arr2:arr2},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);

                    }
                    js.modal.closeLoading();
                    location.reload();
                }
            })
        });
    }

    $(function () {

        /** 加载列表 */
        table = js.table.init({
            url: ctx + "craft/receive/list",
            columns: [
                // {
                //     checkbox: true,
                //     formatter: function (value, row) {
                //         if (row.receiveStatus == 1) {
                //             return {disabled: true}
                //         } else {
                //             return {disabled: false}
                //         }
                //     }
                // },
                {

                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'name'},
                {title: "部分", field: 'part'},
                {
                    title: "清单来源", field: 'drawType',
                    formatter: function (value) {
                        if (value == 1) {

                            return '<span >设计</span>';
                        } else {
                            return '<span >生产</span>';
                        }
                    }
                },
                {title: "设计科室", field: 'sectionName'},
                {title: "设计者", field: 'createNameTwo'},
                {title: "下发日期", field: 'verifyTime'},
                {
                    title: "下发类型", field: 'sheetType',
                    formatter: function (value) {
                        return sheetType[value];
                    }
                },
                {
                    title: "接收状态", field: 'receiveStatus',
                    formatter: function (value) {
                        if (value ==1) {
                            return '<span class="badge label-success">已接收</span>';
                        }else {
                            return '<span class="badge label-inverse">未接收</span>';
                        }
                        // return value == 1 ? '已接收' : '未接收';
                    }
                },
                // {title: "接收日期", field: 'receiveTime'},
                {
                    title: "操作",
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs"  href="' + ctx + 'craft/receive/info/' + row.id + '/'+row.sheetType+'"> 查看</a> ');
                        // actions.push('<a class="btn btn-primary btn-xs" target="_blank" href="' + ctx + 'report/query/print/' + row.id + '"> 打印</a> ');
                        return actions.join('');
                    }
                }
            ]
        });


    });
    function chushihuayuanshi() {
        js.post({
            url: ctx + 'craft/receive/chushihuayuanshi',
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                } else {
                    js.modal.warning(result.msg);

                }
            }
        })
    }
    function chushihua() {
        js.post({
            url: ctx + 'craft/receive/chushihua',
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                } else {
                    js.modal.warning(result.msg);

                }
            }
        })
    }
</script>
</body>
</html>
